package com.fortune.cat.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.config.*;

/**
 * @author zhaozeyang
 * @date 2019/4/23 17:34
 * @description
 */

@Configuration
public class AdminWebAppConfigurer implements WebFluxConfigurer {

    @Override
    public void addCorsMappings(final CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedHeaders("Access-Control-Allow-Origin",
                        "*",
                        "Access-Control-Allow-Methods",
                        "POST, GET, OPTIONS, PUT, DELETE",
                        "Access-Control-Allow-Headers",
                        "Origin, X-Requested-With, Content-Type, Accept")
                .allowedOrigins("*")
                .allowedMethods("*");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/templates/assets/");
    }


}
